/*
 * Copyright (C) ${year} Jeffrey Palm.
 *
 * This code is part of the Floto Project (http://jeffpalm.com/floto/).
 * Please consult the LICENSE included in the distribution.
 */
package com.jeffpalm.floto.isight.util;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JWindow;

public abstract class AbstractSplash extends JWindow {
  
  /** Override this. */
  protected abstract void addRest();
  
  public AbstractSplash(Component guts) {
    this(guts,true);
  }
  
  public AbstractSplash(Component guts, boolean center) {
    setBackground(Color.white);
    setForeground(Color.black);
    getContentPane().add(guts, BorderLayout.CENTER);
    //
    // Add all the rest
    //
    addRest();
    //
    // Build the window
    //
    pack();
    if (center) {
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      Dimension labelSize = guts.getPreferredSize();
      setLocation(screenSize.width/2  - (labelSize.width/2),
                  screenSize.height/2 - (labelSize.height/2));
      screenSize = null;
      labelSize = null;
    }
    setVisible(true);
  }
}